<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>

<%
    String path = request.getContextPath();
    if (path.length() > 0) path = path.substring(0, path.length() - 1);
%>
<jsp:include flush="true" page="/view/inc/incTopScript.jsp"/>
<script>
    function userCheck() {/*用户信息校验*/
        if (document.formAdd.userNowPw.value.length < 1) {
            alert("请输入当前密码");
            document.formAdd.userNowPw.focus();
            return;
        }
        if (document.formAdd.userPw.value.length > 0 && document.formAdd.userPw.value.length < 6) {
            alert("密码需要大于6位");
            document.formAdd.userPw.focus();
            return;
        }
        if (document.formAdd.userRealName.value.length < 2) {
            alert("请输入真实姓名");
            document.formAdd.userPw.focus();
            return;
        }
        var email = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
        if (document.formAdd.userEmail.value.length < 1 || !email.test(document.formAdd.userEmail.value)) {
            alert("请输入正确邮箱地址");
            document.formAdd.userEmail.focus();
            return;
        }
        document.formAdd.submit();
    }
</script>
<form action="<%=path %>/user/edit.action" name="formAdd" method="post">
    <table class="table table-bordered">
        <tr>
            <td width="20%" height="30" align="right" bgcolor="#F9F9F9" style="font-size: 11px;">
                用户名：
            </td>
            <td width="80%">
                ${sessionScope.user.userName }
            </td>
        </tr>
        <tr>
            <td height="30" align="right" bgcolor="#F9F9F9" style="font-size: 11px;">
                密 码：
            </td>
            <td>

                <input type="password" name="userPw"/>
            </td>
        </tr>
        <tr>
            <td height="30" align="right" bgcolor="#F9F9F9" style="font-size: 11px;">
                重复密码：
            </td>
            <td>

                <input type="password" name="userPw2"/>
            </td>
        </tr>
        <tr>
            <td height="30" align="right" bgcolor="#F9F9F9" style="font-size: 11px;">
                真实姓名：
            </td>
            <td>

                <input type="text" name="userRealName" value="${sessionScope.user.userRealName }"/>
            </td>
        </tr>
        <tr>
            <td height="30" align="right" bgcolor="#F9F9F9" style="font-size: 11px;">
                默认邮箱：
            </td>
            <td>

                <input type="text" name="userEmail" value="${sessionScope.user.userEmail }"/>
            </td>
        </tr>
        <tr>
            <td height="30" align="right" bgcolor="#F9F9F9" style="font-size: 11px;">
                联系方式：
            </td>
            <td>
                <input type="text" name="userTel" value="${sessionScope.user.userTel }"/>
            </td>
        </tr>
        <tr>
            <td height="30" align="right" bgcolor="#F9F9F9" style="font-size: 11px;">
                QQ：
            </td>
            <td>
                <input type="text" name="userQq" value="${sessionScope.user.userQq }"/>
            </td>
        </tr>
        <tr>
            <td height="30" align="right" bgcolor="#F9F9F9" style="font-size: 11px;">
                当前用户密码：
            </td>
            <td>
                <input type="password" name="userNowPw"/>
            </td>
        </tr>
        <tr>
            <td height="30" align="right" bgcolor="#F9F9F9">
            </td>
            <td>
                <input type="hidden" name="userId" value="${sessionScope.user.userId}">
                <input type="button" class="btn btn-info" onclick="userCheck()" value="修改"/>
            </td>
        </tr>
    </table>
</form>
<jsp:include flush="true" page="/view/inc/incTopScript.jsp"/>
